package com.ye.spring.proxy;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.springframework.stereotype.Component;

@Component
public class ProxyXml {


    public void beforeMethod(JoinPoint joinPoint) {

        System.out.println("xml-前置通知方法");
    }

    public void afterMethod(JoinPoint joinPoint) {
        System.out.println("xml-后置通知方法");
    }

    public void afterReturningMethod(JoinPoint joinPoint, Object result) {

        System.out.println("xml-after returning 方法");
    }

    public void afterThrowingMethod(JoinPoint joinPoint, Throwable ex) {

        System.out.println("xml-after throwing  方法");
    }

    public Object aroundMethod(ProceedingJoinPoint proceedingJoinPoint) {

        Object res = null;
        try {
            System.out.println("xml-环绕通知前置方法");
            res = proceedingJoinPoint.proceed();
            System.out.println("xml-环绕通知返回方法");
        } catch (Throwable e) {
            System.out.println("xml-环绕通知异常方法");
            e.printStackTrace();
        } finally {
            System.out.println("xml-环绕通知后置方法");
        }
        return res;
    }
}
